<template>
  <!-- 经销商建设过程维护 -->
  <div>
    <BreakSpace label="基本信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel
      ref="baseInfo"
      :list="initFormBase"
      :cols="3"
      :labelWidth="140"
      :isSubmitBtn="false"
      formType="show"
      @formChange="formChangeHandleBase"
    />
    <BreakSpace label="授权信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel
      ref="empowerInfo"
      :list="initFormEmpower"
      :cols="3"
      :labelWidth="140"
      :isSubmitBtn="false"
      formType="show"
      @formChange="formChangeHandleEmpower"
    />
    <BreakSpace label="建设节点信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel
      ref="buildInfo"
      :list="initFormBuild"
      :cols="3"
      :labelWidth="140"
      :isSubmitBtn="false"
      formType="show"
      @formChange="formChangeHandleBuild"
    />
    <BreakSpace label="进度节点信息" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      height='300'
      ref="progressTable"
      :columns="progressColumns"
      :dataSource="progressDataSource"
      :isColumnFilter="false"
      :isSelectColumn="isSelectColumn"
      :datakey="'dealerName'"
      :isToperInfo="false"
      columnsRef='origin_construct_process_index_01'
      :onColumnsChange="columns => this.columns = columns"
    >
    </FilterTable>
    <BreakSpace label="订购节点信息" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      height='300'
      ref="orderTable"
      :columns="orderColumns"
      :dataSource="orderDataSource"
      :isColumnFilter="false"
      :isSelectColumn="isSelectColumn"
      :datakey="'dealerName'"
      :isToperInfo="false"
      columnsRef='origin_construct_process_index_02'
      :onColumnsChange="columns => this.columns = columns"
    >
    </FilterTable>
    <BreakSpace label="总部反馈说明" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      height='100'
      ref="feedbackTable"
      :columns="feedbackColumns"
      :dataSource="feedbackDataSource"
      :isColumnFilter="false"
      :isSelectColumn="isSelectColumn"
      :datakey="'dealerName'"
      :isToperInfo="false"
      columnsRef='origin_construct_process_index_03'
      :onColumnsChange="columns => this.columns = columns"
    >
    <template slot="controls">
        <el-button size="small" type="primary" icon="el-icon-plus" @click="openFeed">查看全部反馈说明</el-button>
      </template>
    </FilterTable>
    <BreakSpace label="施工进度说明" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      height='300'
      ref="photoTable"
      :columns="photoColumns"
      :fetchapi="fetchApiPhoto"
      :isColumnFilter="false"
      :isSelectColumn="isSelectColumn"
      :datakey="'records'"
      :params="fetchParams" 
      :isToperInfo="false"
      columnsRef='origin_construct_process_index_04'
      :onColumnsChange="columns => this.columns = columns"
    >
    <template slot="controls">
        <el-button size="small" type="primary" :disabled="isPass" icon="el-icon-plus" @click="openPhoto('','add')">新增</el-button>
      </template>
    </FilterTable>
    <BreakSpace label="其他施工附件" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel
      ref="fileInfo"
      :list="initFormFile"
      :cols="1"
      :labelWidth="140"
      :isSubmitBtn="false"
      :formType="topFileForm"
      @formChange="formChangeHandleFile"
    />
    <!-- 总部反馈信息弹窗信息弹窗 -->
    <BaseDialog 
      title="总部反馈" 
      width="700px"
      destroyOnClose
      :visible.sync="visibleFeed"
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}" >
      <feed-madal v-model="initDataFeed"  ref="projectDialog" @close="closeFeed" />
    </BaseDialog>
    <!-- 施工进度信息弹窗 -->
    <BaseDialog 
      title="施工进度说明" 
      width="1100px"
      destroyOnClose
      :visible.sync="visiblePhoto"
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}" >
      <photo-madal v-model="initData"  ref="photoDialog" @close="closePhoto" />
    </BaseDialog>
    <div class="btn" style="text-align:right">
      <el-button type="primary" :loading="saveLoading" :disabled="isPass" @click="saveDialog">保存</el-button>
      <el-button type="primary" :loading="saveLoading" :disabled="isPass" @click="submitDialog">提交</el-button>
    </div>
  </div>
</template>
<script>
import photoMadal from './dealerFeedbackAdd'
import feedMadal from './oemFeedback'
import { dictionary } from '@/utils/dictMixin';
import { getDealerApply,searchDealerApplyPnode ,searchDealerApplyOnode,searchDealerApplyOemFeedback,searchDealerApplyDealerFeedback,insertOtherPhoto,insertOtherPhotoSubmit,searchOtherPhoto,deleteDealerFeedbackById} from '@/api/cms-api/origin/construct/dealer';
import { getRegion, getCommunity } from '@/api/cms-common/dealerdata/index';
import { region } from '@/api/cms-common/region';
import * as types from '@/api/cms-api/origin/construct/dealer/types';
import { isArcfox } from '@/api/cms-api/origin/commonDealerType';		//渠道类型工具类

export default {
  components: {
    photoMadal,feedMadal
  },
  mixins: [dictionary,region],
  data() {
    return {
      applyId:"",  //经销商申请ID，进入赋值
      saveLoading: false,
      dealerType:"",  //渠道类型
      saveType:"",  //保存还是提交
      formData:[],
      dealerList:[],
      productList:[],
      dataSource:[],
      progressDataSource:[],
      orderDataSource:[],
      feedbackDataSource:[],
      photoDataSource:[],
      initData: {}, //施工进度弹窗传递参数
      fetchParams:{'searchType':'my'},  //施工进度列表查询参数
      // fetchParams:{"applyId":this.value.rowData.applyId},  //施工进度列表查询参数
      visibleFeed:false,
      visiblePhoto:false,
      isSelectColumn: false,
      initFormBase: this.initFormBaseFun(),     //基本信息-初始化控件
      initFormEmpower: this.initFormEmpowerFun(), //授权信息-初始化控件
      initFormBuild: this.initFormBuildFun(),   //建设节点信息-初始化控件
      progressColumns: this.creatHeaderProgress(),  //进度节点信息-初始化表格头
      orderColumns: this.creatHeaderOrder(),    //订购节点信息-初始化表格头
      feedbackColumns: this.creatHeaderFeedback(),  //总部回馈-初始化表格头
      photoColumns: this.creatHeaderPhoto(),  //施工进度说明-初始化表格头
      initFormFile: this.initFormFileFun(),   //其他施工照片-初始化控件
      initDataFeed:{},  //总部反馈列表弹窗传递参数
      cityData: {},
      fetchApiPhoto: searchDealerApplyDealerFeedback,
      isPass:false, //是否已经审批通过
      topFileForm: 'add'
    };
  },
  mounted() {
    
    this.init();

  },
  computed: {
    
  },
  created() {
    //初始化事业部下拉数据
    this.getDeptData();
    //初始化省份信息
    this.initProvince();
  },
  methods: {
    //修改时，初始化页面数据
    async init(){
      // 更新接口需要的记录 ID
      
      //查询当前登录用户信息
      let res = await getDealerApply({});
      if (res.resultCode === 200) {
        //如果查询结果为null
        if(res.data==null){
          this.isPass = true;
          //施工进度说明区域去掉操作列
          let columnActionPhotoColumns = null;
          this.photoColumns.forEach((x,index) =>{
            if(x.dataIndex === 'column-action'){
              columnActionPhotoColumns = index;
            }
          });
          if(columnActionPhotoColumns != null){
            this.photoColumns.splice(columnActionPhotoColumns,1);
          }

          //设置其他施工附件不可上传
          // this.initFormFile.find(item => item.fieldName === 'fileUrl').disabled = true;
          this.topFileForm = 'show';

          return;
        }

        this.applyId = res.data.applyId;  //赋值入网申请ID
        this.dealerType = res.data.dealerType;  //赋值渠道类型
        

        //初始化所在市，区
        if(res.data['provinceId']){
          this.initCity(res.data['provinceId'],false);
        }
        if(res.data['cityId']){
          this.initTown(res.data['cityId'],false);
        }
        //初始化办事处
        if(res.data['deptId']){
          this.changeDeptSelect(res.data['deptId'],false);
        }
        //初始化渠道类型
        if(res.data['dealerType']){
          this.changeDealerType(res.data['dealerType'],false);
        }

        //判断是否已审核通过
        if(res.data.status == types.BUILD_STATUS_PASS){
          this.isPass = true;
          //施工进度说明区域去掉操作列
          let columnActionPhotoColumns = null;
          this.photoColumns.forEach((x,index) =>{
            if(x.dataIndex === 'column-action'){
              columnActionPhotoColumns = index;
            }
          });
          if(columnActionPhotoColumns != null){
            this.photoColumns.splice(columnActionPhotoColumns,1);
          }

          //设置其他施工附件不可上传
          // this.initFormFile.find(item => item.fieldName === 'fileUrl').disabled = true;
          this.topFileForm = 'show';
        }

        //循环为表单赋值
        //基本信息
        this.initFormBase.forEach(x => {
          if(x.fieldName === 'ownBrandCode'){
            if(res.data[x.fieldName]){
              let list = res.data[x.fieldName].split(',');
              x.initialValue  = list.map(x => parseInt(x));
            }else{
              x.initialValue  = [];
            }
          }else{
            x.initialValue = res.data[x.fieldName];
          }
          // x.initialValue = res.data[x.fieldName];
        });
        this.initFormBase[0].initialValue=res.data.appId.toUpperCase();
        //授权信息
        this.initFormEmpower.forEach(x => {
          x.initialValue = res.data[x.fieldName];
        });
        //建设节点信息
        this.initFormBuild.forEach(x => {
          x.initialValue = res.data[x.fieldName];
        });
        

        //进度节点信息
        let resp = await searchDealerApplyPnode({"currentPage":0,"pageSize":100,"applyId":this.applyId});
        if (resp.resultCode === 200) {
          for(let i in resp.data.records){
              this.progressDataSource.push(Object.assign({},resp.data.records[i]));
          }
        }else {
          this.$notify.error({title: '提示信息',message:'获取进度节点信息失败!'});
        }

        //订购节点信息
        let reso = await searchDealerApplyOnode({"currentPage":0,"pageSize":100,"applyId":this.applyId});
        if (reso.resultCode === 200) {
          for(let i in reso.data.records){
              this.orderDataSource.push(Object.assign({},reso.data.records[i]));
          }
        }else {
          this.$notify.error({title: '提示信息',message:'获取订购节点信息失败!'});
        }

        //总部反馈信息 
        let resf = await searchDealerApplyOemFeedback({"currentPage":0,"pageSize":2,"applyId":this.applyId});
        if (resf.resultCode === 200) {
          for(let i in resf.data.records){
              this.feedbackDataSource.push(Object.assign({},resf.data.records[i]));
          }
        }else {
          this.$notify.error({title: '提示信息',message:'获取总部反馈信息失败!'});
        }
        
        //查询其他施工照片
        let resop = await searchOtherPhoto({},this.applyId);
        if (resop.resultCode === 200) {
            this.initFormFile.forEach(x => {
              let urlsList = resop.data.urls;
              if(urlsList!=null && urlsList.length>0){
                let fileList = [];
                for(let i in urlsList){
                    let fileName = { name: urlsList[i].fileName };
                    let fileId = { url: urlsList[i].fileId };
                    let f = Object.assign(fileName, fileId);
                    fileList.push(f);
                }
                x.initialValue = fileList;
              }
            });

        }else {
          this.$notify.error({title: '提示信息',message:'获取其他施工照片信息失败!'});
        }
        

      }else {
        this.$notify.error({title: '提示信息',message:res.errMsg||'获取入网信息失败!'});
        // this.closeDialog();
      }
      

      

      this.$nextTick(() => {
        //清除顶部表单进入校验提示信息
        this.$refs.baseInfo.$refs.form.clearValidate();
        this.$refs.empowerInfo.$refs.form.clearValidate();
        this.$refs.buildInfo.$refs.form.clearValidate();
      });
      
    },
   
    //基本信息数据
    initFormBaseFun() {
      return [
         {//0
          type: 'INPUT',
          label: '品牌',
          fieldName: 'brandIdTmp',
          // fieldName: 'appId',
          placeholder: '',
          initialValue: '',
          disabled:true
        },
        {//1
          type: 'INPUT',
          label: '经销商简称',
          fieldName: 'dealerShortname',
          placeholder: '',
          initialValue: '',
          
        },
        {//2
          type: 'INPUT',
          label: '临时代码',
          fieldName: 'dealerCode',
          placeholder: '',
          initialValue: '系统自动生成',
          // readonly : true,
          disabled:true,
          
        },
        {//3
          type: 'INPUT',
          label: '公司全称',
          fieldName: 'dealerName',
          placeholder: '',
          initialValue: '',
          selfCols:3,
          
        },
        {//4
          type: 'SELECT',
          label: '渠道类型',
          fieldName: 'dealerType',
          placeholder: '',
          initialValue: '',
          itemList: this.createDictListRemoveCodes('2538',['25381004','25381005','25381006']),
          change: val => {
            this.changeDealerType(val);
          },
          
        },
        // { //5
        //   type: 'SELECT', 
        //   label: '细分类别', 
        //   fieldName: 'subType', 
        //   placeholder: '请选择', 
        //   initialValue: '', 
        //   hidden: !isArcfox() ,
        //   itemList: this.createDictList('2539'),
				// },
        {//6
          type: 'SELECT',
          label: '经销商级别',
          fieldName: 'shopLevel',
          placeholder: '',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('2540'),
          
        },
        {//7
          type: 'SELECT',
          label: '事业部',
          fieldName: 'deptId',
          placeholder: '',
          initialValue: '',
          itemList: [],
          change: val => {
            this.changeDeptSelect(val);
          },
          
        },
        {//8
          type: 'SELECT',
          label: '办事处',
          fieldName: 'officeId',
          placeholder: '',
          initialValue: '',
          itemList: [],
          
        },
        {//9
          type: 'SELECT',
          label: '建设类型',
          fieldName: 'constructType',
          placeholder: '',
          initialValue: '',
          itemList: this.createDictList('2541'),
          
        },
        {//10
          type: 'SELECT',
          label: '省份',
          fieldName: 'provinceId',
          placeholder: '',
          initialValue: "",
          change: (value) => {
            this.initCity(value)
          },
          itemList:  [],
          
        },
        {//11
          type: 'SELECT',
          label: '城市',
          fieldName: 'cityId',
          placeholder: '',
          initialValue: "",
          itemList: [],
          change: (value) => {
            this.initTown(value)
          },
          
        },
        {//12
          type: 'SELECT',
          label: '县区',
          fieldName: 'districtId',
          placeholder: '',
          initialValue: "",
          itemList:  [],
          
        },
        {//22
          type: 'INPUT',
          label: '建设地址',
          fieldName: 'constructAddress',
          placeholder: '',
          initialValue: '',
          selfCols:3,
          
        },
        {//13
          type: 'INPUT',
          label: '店端主要联系人',
          fieldName: 'dealerLinkman',
          placeholder: '',
          initialValue: '',
          
        },
        {//14
          type: 'INPUT',
          label: '联系人电话',
          fieldName: 'dealerPhone',
          placeholder: '',
          initialValue: '',
          
        },
        {//15
          type: 'INPUT',
          label: '店端联系人邮箱',
          fieldName: 'dealerEmail',
          placeholder: '',
          initialValue: '',
          
        },
        {//16
          type: 'INPUT',
          label: '厂家负责人',
          fieldName: 'oemLinkman',
          placeholder: '',
          initialValue: '',
          
        },
        {//17
          type: 'INPUT',
          label: '负责人电话',
          fieldName: 'oemPhone',
          placeholder: '',
          initialValue: '',
          
        },
        // {//18
        //   type: 'SELECT',
        //   label: '展厅级别',
        //   fieldName: 'salesLevel',
        //   placeholder: '',
        //   initialValue: '',
        //   itemList: this.createDictList('2542')
        // },
        {//19
          type: 'INPUT',
          label: '项目设计师',
          fieldName: 'projectDesigner',
          placeholder: '',
          initialValue: '',
          
        },
        {//20
          type: 'INPUT',
          label: '设计师电话',
          fieldName: 'designerPhone',
          placeholder: '',
          initialValue: '',
          
        },
        // {//21
        //   type: 'SELECT',
        //   label: '售后级别',
        //   fieldName: 'serviceLevel',
        //   placeholder: '',
        //   initialValue: '',
        //   itemList: this.createDictList('2543')
        // },
        
        { type: 'MULTIPLE_SELECT', 
          label: '体系内品牌', 
          fieldName: 'ownBrandCode', 
          placeholder: '', 
          initialValue: [], 
          itemList: this.createDictList('2545')
        }
      ];
    },
    //授权信息数据
    initFormEmpowerFun() {
      return [
         {
          type: 'SELECT',
          label: '是否边建边销',
          fieldName: 'isSaling',
          placeholder: '',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('1004'),
          
        },
        {
          type: 'SELECT',
          label: '是否边建边修',
          fieldName: 'isServicing',
          placeholder: '',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('1004'),
          
        },
        {
          type: 'INPUT',
          label: '临时工时',
          fieldName: 'tempLabour',
          placeholder: '',
          initialValue: '',
          hidden:false,
          precision:2
        }
        
      ];
    },
    //建设节点信息数据
    initFormBuildFun() {
      return [
        {
          type: 'DATE',
          label: '协议开工时间',
          fieldName: 'agreementOpenTime',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '',
          style: { width: '100%' }
        },
        {
          type: 'DATE',
          label: '实际开工时间',
          fieldName: 'actualOpenTime',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '',
          style: { width: '100%' }
        },
        {
          type: 'DATE',
          label: '协议完工时间',
          fieldName: 'agreementFinishTime',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '',
          style: { width: '100%' }
        },
        {
          type: 'SELECT',
          label: '建设状态节点',
          fieldName: 'buildStatus',
          placeholder: '',
          initialValue: '',
          itemList: this.createDictList('2546')
        },
        {
          type: 'INPUT',
          label: '总体建设进度',
          fieldName: 'buildProcess',
          initialValue: '',
          placeholder: '',
          unitRender: () => {
            return <el-button slot="append">%</el-button>;
          }
        },
        {
          type: 'DATE',
          label: '实际完工时间',
          fieldName: 'actualFinishTime',
          style: { width: '100%' },
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: ''
        }
        
      ];
    },

    //进度节点列表表头
    creatHeaderProgress() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },
        {
          title: '进度节点类型',
          dataIndex: 'nodeType',
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.nodeType, '2547')}</span>;
          }
        },
        { title: '时间', dataIndex: 'nodeTime', dateFormat:'yyyy-MM-dd',sorter: true },
        {
          title: '附件',
          dataIndex: 'urls',
          sorter: true,
          render: props => {
            let fileStr=[];
            for(let i in props.row.urls){
              fileStr.push(<a href={props.row.urls[i].fileId} style='color:blue' target="_blank">{props.row.urls[i].fileName}</a>);
                // fileStr.push(
                //   <el-popover
                //   width="140"
                //   trigger="click"
                //   >
                //   <el-image  style="width: 140px; height: 140px" 
                //    src={props.row.urls[i].fileId}  
                //    preview-src-list={[props.row.urls[i].fileId]} 
                //    onClick={() => this.imgLick(props.row.urls[i])}></el-image>
                //   <el-button slot="reference" type="text" >{props.row.urls[i].fileName}</el-button>
                // </el-popover>
                  
                //   );
            }
            return <span>{fileStr}</span>;
          }
        }
      ];
    },

    //订购节点列表表头
    creatHeaderOrder() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },
        { title: '订购节点类型', dataIndex: 'onodeType', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.onodeType, '2548')}</span>;
        }},
        { title: '订购时间', dataIndex: 'orderTime',dateFormat:'yyyy-MM-dd', sorter: true },
        { title: '到货时间', dataIndex: 'arrivalTime',dateFormat:'yyyy-MM-dd', sorter: true},
        { title: '订购金额', dataIndex: 'orderFee',numberFormat:true,  sorter: true},
        { title: '安装时间', dataIndex: 'installTime',dateFormat:'yyyy-MM-dd', sorter: true}
      ];
    },
    //总部反馈列表表头
    creatHeaderFeedback () {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },
        { title: '执行反馈状态', dataIndex: 'feedbackStatus', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.feedbackStatus, '2549')}</span>;
        }},
        { title: '周度', dataIndex: 'feedbackWeek', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.feedbackWeek, '2576')}</span>;
        }},
        { title: '时间', dataIndex: 'feedbackTime',dateFormat:'yyyy-MM-dd', sorter: true},
        { title: '进度说明', dataIndex: 'processDesc', sorter: true},
        { title: '整改项目', dataIndex: 'reformItem', sorter: true}
      ];
    },
    //施工进度说明列表表头
    creatHeaderPhoto() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 100,
          fixed: 'left',
          render: (props, h) => {
            return (
              <div>
                <el-button size="mini" type="text" onClick={() => this.openPhoto(props.row,'edit')}>
                  编辑
                </el-button>
               <el-button size="mini" type="text" onClick={() => this.delPhoto(props.row)}>删除</el-button>
              </div>
            );
          }
          // <el-button size="mini" type="text" onClick={() => this.openPhoto(props.row,'show')}>明细</el-button>
        },
        { title: '项目', dataIndex: 'constructionNamePra', sorter: true },
        { title: '子项目', dataIndex: 'constructionName', sorter: true },
        { title: '附件', dataIndex: 'urls', 
          render: props => {
            let fileStr=[];
            for(let i in props.row.urls){
                fileStr.push(<a href={props.row.urls[i].fileId} style='color:blue' target="_blank">{props.row.urls[i].fileName}</a>);
                // fileStr.push(
                //   <el-popover
                //   width="140"
                //   trigger="click"
                //   >
                //   <el-image  style="width: 140px; height: 140px" 
                //    src={props.row.urls[i].fileId}  
                //    preview-src-list={[props.row.urls[i].fileId]} 
                //    onClick={() => this.imgLick(props.row.urls[i])}></el-image>
                //   <el-button slot="reference" type="text" >{props.row.urls[i].fileName}</el-button>
                // </el-popover>
                  
                //   );
            }
            return <span>{fileStr}</span>;
          }
        },
        { title: '上传日期', dataIndex: 'updatedAt', sorter: true,dateFormat:'yyyy-MM-dd', },
        { title: '审核结果', dataIndex: 'auditResult', sorter: true ,
          render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.auditResult, '2550')}</span>;
          }
        },
        { title: '审核说明', dataIndex: 'auditDesc',  sorter: true  }
      ];
    },
    //附件信息数据
    initFormFileFun() {
      return [
        {
          type: 'UPLOAD_FILE',
          label: '其他施工附件',
          fieldName: 'fileUrl',
          initialValue: '',
          upload: {
            limit:0,
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'jpeg', 'png', 'gif', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf', 'rar', 'zip'],
            max:1024*30
          }
        }
      ];
    },
    //渠道类型切换
    changeDealerType(type,flag=true) {
      if (type) {
        //如果为4s店 展厅级别和售后级别都显示 经销商级别显示
        if(type === types.DEALER_TYPE_4S){
          this.$nextTick(() =>{
            if(flag){
              // this.initFormBase.find(item => item.fieldName === 'salesLevel').initialValue = undefined;
              // this.initFormBase.find(item => item.fieldName === 'serviceLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'shopLevel').initialValue = undefined;
            }
            // this.initFormBase.find(item => item.fieldName === 'salesLevel').hidden = false;
            // this.initFormBase.find(item => item.fieldName === 'serviceLevel').hidden = false;
            this.initFormBase.find(item => item.fieldName === 'shopLevel').hidden = false;
          } )
          //是否边建边销和是否边建边修显示并必填
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').initialValue = '';
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').hidden = false;


        //如果为单一销售 展厅级别显示，售后级别隐藏  经销商级别显示
        }else if(type === types.DEALER_TYPE_SINGLE_SALE){
          this.$nextTick(() =>{
            if(flag){
              // this.initFormBase.find(item => item.fieldName === 'salesLevel').initialValue = undefined;
              // this.initFormBase.find(item => item.fieldName === 'serviceLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'shopLevel').initialValue = undefined;
            }
            // this.initFormBase.find(item => item.fieldName === 'salesLevel').hidden = false;
            // this.initFormBase.find(item => item.fieldName === 'serviceLevel').hidden = true;
            this.initFormBase.find(item => item.fieldName === 'shopLevel').hidden = false;
          } )
          //是否边建边销显示并必填 ,是否边建边修不显示 临时工时不显示
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').hidden = true;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').initialValue = '';
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').hidden = true;


        //如果为单一售后  售后级别显示，展厅级别隐藏 经销商级别显示
        }else if(type === types.DEALER_TYPE_SINGLE_AFTER){
          this.$nextTick(() =>{
            if(flag){
              // this.initFormBase.find(item => item.fieldName === 'salesLevel').initialValue = undefined;
              // this.initFormBase.find(item => item.fieldName === 'serviceLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'shopLevel').initialValue = undefined;
            }
            // this.initFormBase.find(item => item.fieldName === 'salesLevel').hidden = true;
            // this.initFormBase.find(item => item.fieldName === 'serviceLevel').hidden = false;
            this.initFormBase.find(item => item.fieldName === 'shopLevel').hidden = false;
          } )
          //是否边建边销不显示 ,是否边建边修显示并必填
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').hidden = true;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').initialValue = '';
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').hidden = false;

        //如果为SPACE和RACE  经销商级别、展厅级别、售后级别字段不显示
        }else if(type === types.DEALER_TYPE_DIRECT_SHOP || type === types.DEALER_TYPE_NOT_DIRECT_SHOP){
          this.$nextTick(() =>{
            if(flag){
              // this.initFormBase.find(item => item.fieldName === 'salesLevel').initialValue = undefined;
              // this.initFormBase.find(item => item.fieldName === 'serviceLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'shopLevel').initialValue = undefined;
            }
            // this.initFormBase.find(item => item.fieldName === 'salesLevel').hidden = true;
            // this.initFormBase.find(item => item.fieldName === 'serviceLevel').hidden = true;
            this.initFormBase.find(item => item.fieldName === 'shopLevel').hidden = true;
          } )
          //边建边销要保留,是否边建边修、临时工时隐藏
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').hidden = true;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').initialValue = '';
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').hidden = true;

        }
      }
    },
    //获取事业部下拉列表数据
    async getDeptData() {
      const res = await getRegion();
      if (res.resultCode === 200) {
        this.initFormBase.find(item => item.fieldName === 'deptId').itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
      }
    },

    //事业部下拉改变执行方法，级联查询该事业部下的办事处
    async changeDeptSelect(deptId,flag = true) {
      if(flag){
        this.initFormBase.find(item => item.fieldName === 'officeId').initialValue = '';
        this.initFormBase.find(item => item.fieldName === 'officeId').itemList = [];
      }
      if (!deptId) {
      } else {
        const res = await getCommunity(deptId);
        if (res.resultCode === 200) {
         this.initFormBase.find(item => item.fieldName === 'officeId').itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
        }
      }
    },

    //初始化所在省份
    async initProvince(){
      let pl = this.createRegionList();
      this.initFormBase.find(item => item.fieldName === 'provinceId').itemList = pl;
      // this.initFormBase[19].itemList = pl;
    },
    //初始化所在市数据
    async initCity(provinceId,flag = true){
      if(flag){
        //清空市
        this.initFormBase.find(item => item.fieldName === 'cityId').initialValue="";
        this.initFormBase.find(item => item.fieldName === 'cityId').itemList = [];
        //清空县
        this.initFormBase.find(item => item.fieldName === 'districtId').initialValue="";
        this.initFormBase.find(item => item.fieldName === 'districtId').itemList=[];
      }

      if(!provinceId || provinceId==null || typeof(provinceId)=='undefined'){
        return;
      }
      //取省数据
      let rd = this.getRegionData();
      this.cityData = rd[provinceId].children;
      let cl = this.createSubRegionList(this.cityData);
      this.initFormBase.find(item => item.fieldName === 'cityId').itemList = cl;
    },
    //初始化所在县数据
    async initTown(cityId,flag = true){
      if(flag){
        //清空县
        this.initFormBase.find(item => item.fieldName === 'districtId').initialValue="";
        this.initFormBase.find(item => item.fieldName === 'districtId').itemList=[];
      }
      if(!cityId || cityId==null || typeof(cityId)=='undefined'){
        return;
      }
      let td = this.cityData[cityId].children;
      let tl = this.createSubRegionList(td);
      this.initFormBase.find(item => item.fieldName === 'districtId').itemList = tl;
    },
    // 基础信息表单数据获取  
    formChangeHandleBase(data){
      this.formData.base = data;
    },
    // 授权信息表单数据获取  
    formChangeHandleEmpower(data){
      this.formData.empower = data;
    },
    //建设节点信息表单数据获取  
    formChangeHandleBuild(data){
      
    },

    //其他施工菜单
    formChangeHandleFile(data){
      this.formData = data;
      if(this.saveType == "save"){
        this.doSaveDialog();
      }else if(this.saveType == "submit"){
        this.doSubmitDialog();
      }
    },
    //保存按钮
    saveDialog(){
      this.saveType = "save";
      this.$refs.fileInfo.SUBMIT_FORM();
    },
    //提交按钮   
    submitDialog(){
      this.saveType = "submit";
      this.$refs.fileInfo.SUBMIT_FORM();
    },
    //执行保存
    async doSaveDialog(){
      this.saveLoading = true;
      let fileUrlList = [];
      //获取附件，转为list类型
      for (let i = 0; i < this.formData.fileUrl.length; i++) {
        fileUrlList.push(Object.assign({},{"name":this.formData.fileUrl[i].name},{"url":this.formData.fileUrl[i].url}));
      }

      let submitData = Object.assign({},{"applyId":this.applyId});
      submitData.filesInfo = fileUrlList;
      
      let res = await insertOtherPhoto(submitData);
      if (res.resultCode === 200) {
        this.$notify.success({title: '提示信息',message:'保存成功!'});
        this.saveLoading = false;
        // // 重新加载
        // this.closeDialog('refresh');
      }else {
        this.$notify.error({title: '提示信息',message:res.errMsg||'保存失败!'});
        this.saveLoading = false;
        // this.closeDialog();
      }

    },
    //执行提交
    async doSubmitDialog(){
      this.saveLoading = true;
      let fileUrlList = [];
      //获取附件，转为list类型
      for (let i = 0; i < this.formData.fileUrl.length; i++) {
        fileUrlList.push(Object.assign({},{"name":this.formData.fileUrl[i].name},{"url":this.formData.fileUrl[i].url}));
      }

      let submitData = Object.assign({},{"applyId":this.applyId});
      submitData.filesInfo = fileUrlList;
      
      let res = await insertOtherPhotoSubmit(submitData);
      if (res.resultCode === 200) {
        this.$notify.success({title: '提示信息',message:'提交成功!'});
        // 刷新列表数据
        this.fetchParams = { ...this.fetchParams };
        this.saveLoading = false;
        // // 重新加载
        // this.closeDialog('refresh');
      }else {
        this.$notify.error({title: '提示信息',message:res.errMsg||'提交失败!'});
        this.saveLoading = false;
        // this.closeDialog();
      }

    },
    //取消操作
    closeDialog(type) {
      this.$emit('close', { visible: false,type:type});
    },
    // 总部反馈 打开窗口 -传数据
    openFeed() {
      const pram = {
        applyId: this.applyId
      };
      this.initDataFeed=pram;
      this.visibleFeed = true;
    },
    // 总部反馈 关闭窗口 -返回数据
    closeFeed(data) {
      this.visibleFeed = data.visible; //关闭弹窗
    },
    // 施工进度反馈 打开窗口 -传数据
    openPhoto(row,type) {
      const pram = {
        type: type,
        rowData: row,
        applyId: this.applyId,
        dealerType:this.dealerType
      };
      this.initData=pram;
      this.visiblePhoto = true;
    },
    // 施工进度反馈 关闭窗口 -返回数据
    closePhoto(data) {
      this.visiblePhoto = data.visible; //关闭弹窗
      if (data.type === 'refresh') {
        // 刷新列表数据
        this.fetchParams = { ...this.fetchParams };
      }
    },
    // 删除施工进度按钮
    async delPhoto(row) {
      this.$confirm('是否确定删除?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(async() => {
          
          let res = await deleteDealerFeedbackById(row.applyDealerFeedbackId);
          if (res.resultCode === 200) {
            this.$notify.success({title: '提示信息',message:'删除成功!'});
            // 刷新列表数据
            this.fetchParams = { ...this.fetchParams };
          }else {
            this.$notify.error({title: '提示信息',message:res.errMsg||'删除失败!'});
          }
          
				}).catch(() => {});
    }
  }
};
</script>

<style lang="less" scoped>
</style>
